const http = require("http");

function file_get_contents(args, callback) {
  var url = args[0];
  http.get(url, (res) => {
    let rawData = "";
    res.on("data", (chunk) => {
      rawData += chunk;
    });
    res.on("end", () => {
      callback(rawData);
    });
  });
}

function sleep(args, callback) {
  var time = args[0] * 1000;
  setTimeout(callback, time);
}

function usleep(args, callback) {
  var time = parseInt(args[0] / 1000);
  setTimeout(callback, time);
}

module.exports = {
  file_get_contents,
  sleep,
  usleep
};
